package apple.encryptedNode.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class EncryptedNodeOpenHelper extends SQLiteOpenHelper {
    private static final int DATABASE_VERSION = 2;
    public static final String DATABASE_NAME = "EncryptedNotes";
    public static final String DICTIONARY_TABLE_NAME = "EncryptedNote";
	public static final String KEY_NAME = "fileName";
	public static final String KEY_CONTENT = "fileContent";
	private static final String DICTIONARY_TABLE_CREATE = "CREATE TABLE "
		+ DICTIONARY_TABLE_NAME + " (" 
		+ "_id INTEGER primary key autoincrement, "
		+ KEY_NAME + " TEXT, " 
		+ KEY_CONTENT + " TEXT);";

	public EncryptedNodeOpenHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		Log.e("Adam", "sql: "+DICTIONARY_TABLE_CREATE);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		Log.e("Adam", "sql: "+DICTIONARY_TABLE_CREATE);
		db.execSQL(DICTIONARY_TABLE_CREATE);
		db.execSQL("insert into EncryptedNote values( 0,'apple','this is my first application');");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        String  sql="drop table if exists "+ DICTIONARY_TABLE_NAME;
        db.execSQL(sql);
        onCreate(db);

	}

}
